package router

import (
	"gin.project.template/config"
	"gin.project.template/handler"
	"gin.project.template/middleware"
	"github.com/gin-gonic/gin"
)

func SetupRouters() *gin.Engine {

	engine := gin.New()
	//engine.Use(config.GinLogger, config.GinRecovery(true))
	engine.Use(config.GinLogger)

	base := engine.Group("/api/v1")

	// 不需要鉴权的接口
	publicGroup := base.Group("")
	{
		publicGroup.GET("/alive", handler.Alive)
		publicGroup.GET("/login", handler.Login)
	}

	// 需要鉴权的接口
	privateGroup := base.Group("")
	privateGroup.Use(middleware.JWTAuthMiddleware())
	{
		privateGroup.GET("/user", handler.UserProfile)
	}

	return engine
}
